﻿<Window x:Class="LockCrypt.WinMain"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:props="clr-namespace:LockCrypt.Properties"
    xmlns:l49ui="clr-namespace:Lime49.UI;assembly=Lime49"
    xmlns:conv="clr-namespace:LockCrypt.Converters"
    xmlns:loc="clr-namespace:LockCrypt"
    xmlns:lex="http://schemas.root-project.org/xaml/presentation"
    Topmost="{Binding ElementName=itmTopMost,Path=IsChecked}"
    Title="LockCrypt" Loaded="Window_Loaded"
    Width="800" Height="710"
    Style="{StaticResource {x:Type Window}}" Icon="/LockCrypt;component/Resources/LockCrypt.ico">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Close" Executed="CloseWindow" />
        <CommandBinding Command="ApplicationCommands.Delete" Executed="DeleteItem" CanExecute="IsItemSelected" />
        <CommandBinding Command="ApplicationCommands.Find" Executed="Search" CanExecute="IsDbValid" />
        <CommandBinding Command="ApplicationCommands.Help" Executed="ShowHelp" />
        <CommandBinding Command="ApplicationCommands.New" Executed="AddAccount" CanExecute="IsDbValid" />
        <CommandBinding Command="ApplicationCommands.Print" Executed="Print" CanExecute="IsDbValid"  />
        <CommandBinding Command="ApplicationCommands.Properties" Executed="EditItem" CanExecute="IsItemSelected" />
        <CommandBinding Command="ApplicationCommands.Open" Executed="OpenDatabase" />
        <CommandBinding Command="ApplicationCommands.Save" Executed="Export" CanExecute="IsDbValid"  />
        <CommandBinding Command="EditingCommands.Delete" Executed="DeleteFieldFilter" CanExecute="IsFieldFilterSelected" />
        <CommandBinding Command="NavigationCommands.Refresh" Executed="ReloadDatabase" CanExecute="CanAlwaysExecute" />
        <CommandBinding Command="loc:LockCryptCommands.About" Executed="ShowAbout" />
        <CommandBinding Command="loc:LockCryptCommands.Add" Executed="AddFieldFilter" />
        <CommandBinding Command="loc:LockCryptCommands.Edit" Executed="EditFieldFilter" CanExecute="IsFieldFilterSelected" />
        <CommandBinding Command="loc:LockCryptCommands.AddDummyData" Executed="AddDummyData" CanExecute="IsWorkerBusy" />
        <CommandBinding Command="loc:LockCryptCommands.AddGroup" Executed="AddGroup" CanExecute="CanAddGroup" />
        <CommandBinding Command="loc:LockCryptCommands.AutoType" Executed="AutoType" CanExecute="IsItemSelected" />
        <CommandBinding Command="loc:LockCryptCommands.ChangeView" Executed="ChangeView" CanExecute="CanAlwaysExecute" />
        <CommandBinding Command="loc:LockCryptCommands.ChangePassword" Executed="ChangePassword" CanExecute="IsWorkerBusy" />
        <CommandBinding Command="loc:LockCryptCommands.ClearDatabase" Executed="ClearDatabase" CanExecute="IsWorkerBusy" />
        <CommandBinding Command="loc:LockCryptCommands.CreateCopy" Executed="CreateCopy" CanExecute="IsItemSelected" />
        <CommandBinding Command="loc:LockCryptCommands.CreateDatabase" Executed="CreateDatabase" />
        <CommandBinding Command="loc:LockCryptCommands.GeneratePassword" Executed="ShowPasswordGenerator"/>
        <CommandBinding Command="loc:LockCryptCommands.Import" Executed="Import" CanExecute="IsDbValid" />
        <CommandBinding Command="loc:LockCryptCommands.Options" Executed="ShowOptions"/>
        <CommandBinding Command="loc:LockCryptCommands.Relock" Executed="FireRelock" CanExecute="IsDbValid" />
        <CommandBinding Command="loc:LockCryptCommands.ShowTemplates" Executed="ShowTemplates" CanExecute="IsWorkerBusy" />
        <CommandBinding Command="loc:LockCryptCommands.Synchronize" Executed="Synchronize" CanExecute="IsDbValid" />
        <CommandBinding Command="loc:LockCryptCommands.VersionCheck" Executed="CheckForNewVersion" />
    </Window.CommandBindings>
    <Window.Resources>
        <props:Settings x:Key="Settings" />
        <conv:NestableToVisibilityConverter x:Key="NestableToVisibilityConverter"/>
        <conv:ViewPreferenceConverter x:Key="ViewPreferenceConverter"/>
        <conv:TreeTemplateSelector x:Key="TreeTemplateSelector" AccountTemplate="{StaticResource TreeViewAccountTemplate}" GroupTemplate="{StaticResource TreeViewGroupTemplate}"/>
        <conv:BooleanInverter x:Key="BooleanInverter"/>
        <BitmapImage x:Key="srcadd_16" x:Shared="False" UriSource="pack://application:,,,/Resources/Images/add_16.png"/>
        <BitmapImage x:Key="srcdelete_16" x:Shared="False" UriSource="pack://application:,,,/Resources/Images/delete_16.png"/>
        <Image x:Key="add_16" x:Shared="False" Source="{StaticResource srcadd_16}"/>
        <Image x:Key="copy_16" x:Shared="false" Source="pack://application:,,,/Resources/Images/copy_16.png"/>
        <Image x:Key="edit_16" x:Shared="False" Source="pack://application:,,,/Resources/Images/edit_16.png"/>
        <Image x:Key="delete_16" x:Shared="False" Source="{StaticResource srcdelete_16}"/>
        <Image x:Key="keyboard_16" x:Shared="False" Source="pack://application:,,,/Resources/Images/keyboard_16.png"/>
        <Image x:Key="new_16" x:Shared="False" Source="pack://application:,,,/Resources/Images/new_16.png"/>
        <Image x:Key="open_16" x:Shared="False" Source="pack://application:,,,/Resources/Images/folder_closed_16.png"/>
        <Image x:Key="print_16" x:Shared="False" Source="pack://application:,,,/Resources/Images/print_16.png"/>
        <Image x:Key="save_16" x:Shared="False" Source="pack://application:,,,/Resources/Images/save_16.png"/>
        <Image x:Key="settings_16" x:Shared="False" Source="pack://application:,,,/Resources/Images/settings_16.png"/>
        <Image x:Key="view_details_16" x:Shared="False" Source="pack://application:,,,/Resources/Images/view_details_16.png"/>
        <Image x:Key="view_largeicons_16" x:Shared="False" Source="pack://application:,,,/Resources/Images/view_largeicons_16.png"/>
        <Image x:Key="view_smallicons_16" x:Shared="False" Source="pack://application:,,,/Resources/Images/view_smallicons_16.png"/>
        <Image x:Key="view_tiles_16" x:Shared="False" Source="pack://application:,,,/Resources/Images/view_tiles_16.png"/>
        <CollectionViewSource x:Key="templateSource"/>
        <CollectionViewSource x:Key="filterTypeSource"/>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Key="F3" Command="ApplicationCommands.Find" CommandParameter="toggle"/>
    </Window.InputBindings>
    <Grid x:Name="grdContainer" DataContext="{StaticResource Settings}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="180" MinWidth="120" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Menu Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left">
            <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:File}">
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:New}" Icon="{StaticResource new_16}">
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Account}" Command="ApplicationCommands.New" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Group}" Command="loc:LockCryptCommands.AddGroup" />
                    <Separator/>
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Database}" Command="loc:LockCryptCommands.CreateDatabase" />
                </MenuItem>
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Open}" Icon="{StaticResource open_16}">
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:XmlFile}" Command="ApplicationCommands.Open" CommandParameter="xml" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:SQLiteDatabase}" Command="ApplicationCommands.Open" CommandParameter="sqlite" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:MySqlDatabase}" Command="ApplicationCommands.Open" CommandParameter="mysql" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:LegacyDatabase}" Command="ApplicationCommands.Open" CommandParameter="legacy" />
                </MenuItem>
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:SaveAs}" Icon="{StaticResource save_16}">
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:XmlFile}" Command="ApplicationCommands.Save" CommandParameter="xml" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:SQLiteDatabase}" Command="ApplicationCommands.Save" CommandParameter="sqlite" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:LegacyDatabase}" Command="ApplicationCommands.Save" CommandParameter="legacy" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:DatabaseDescriptor}" Command="ApplicationCommands.Save" CommandParameter="descriptor" />
                    <Separator/>
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:HtmlFile}" Command="ApplicationCommands.Save" CommandParameter="html" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:CsvFile}" Command="ApplicationCommands.Save" CommandParameter="csv" />
                </MenuItem>
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Import}">
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:LegacyXmlFile}" Command="loc:LockCryptCommands.Import" CommandParameter="legacyxml" />
                    <MenuItem Header="Keepass 2.x XML File" Command="loc:LockCryptCommands.Import" CommandParameter="keepass2x" />
                </MenuItem>
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Print}" Command="ApplicationCommands.Print" Icon="{StaticResource print_16}" />
                <Separator/>
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:ChangePassword}" Command="loc:LockCryptCommands.ChangePassword" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:ReloadDatabase}" Command="NavigationCommands.Refresh" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Relock}" Command="loc:LockCryptCommands.Relock" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:CloseDatabase}" Command="loc:LockCryptCommands.Relock" CommandParameter="true"  />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Exit}" Command="ApplicationCommands.Close" />
            </MenuItem>
            <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Edit}">
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Edit}" Command="ApplicationCommands.Properties" Icon="{StaticResource edit_16}" CommandParameter="-1" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Delete}" Command="ApplicationCommands.Delete" Icon="{StaticResource delete_16}" CommandParameter="-1" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:CreateCopy}" Command="loc:LockCryptCommands.CreateCopy" Icon="{StaticResource copy_16}" CommandParameter="-1" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:AutoType}" Command="loc:LockCryptCommands.AutoType" Icon="{StaticResource keyboard_16}" ToolTip="{lex:LocText LockCrypt.Core:Strings:AutoTypeSelected}"/>
                <Separator/>
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Templates}" Command="loc:LockCryptCommands.ShowTemplates" />
            </MenuItem>
            <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:View}">
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:LargeIcons}" Command="loc:LockCryptCommands.ChangeView" CommandParameter="largeicons" IsChecked="{Binding Default.PrefferedView,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource ViewPreferenceConverter},ConverterParameter=largeicons}" Checked="SavePreferences" Icon="{StaticResource view_details_16}" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:SmallIcons}" Command="loc:LockCryptCommands.ChangeView" CommandParameter="smallicons" IsChecked="{Binding Default.PrefferedView,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource ViewPreferenceConverter},ConverterParameter=smallicons}" Checked="SavePreferences" Icon="{StaticResource view_largeicons_16}" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Details}" Command="loc:LockCryptCommands.ChangeView" CommandParameter="details" IsChecked="{Binding Default.PrefferedView,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource ViewPreferenceConverter},ConverterParameter=details}" Checked="SavePreferences" Icon="{StaticResource view_smallicons_16}" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Tiles}" Command="loc:LockCryptCommands.ChangeView" CommandParameter="tiles" IsChecked="{Binding Default.PrefferedView,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource ViewPreferenceConverter},ConverterParameter=tiles}" Checked="SavePreferences" Icon="{StaticResource view_tiles_16}" />
            </MenuItem>
            <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Tools}">
                <MenuItem x:Name="itmTopMost" Header="{lex:LocText LockCrypt.Core:Strings:AlwaysOnTop}" IsCheckable="True" IsChecked="{Binding Default.AlwaysOnTop,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Checked="SaveAlwaysOnTop" Unchecked="SaveAlwaysOnTop" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Synchronize}" Command="loc:LockCryptCommands.Synchronize" ToolTip="{lex:LocText LockCrypt.Core:Strings:SynchronizeWithMobileDevice}" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:ExampleData}">
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:RestoreDefaultAccounts}" Command="loc:LockCryptCommands.AddDummyData" CommandParameter="accounts" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:RestoreDefaultTemplates}" Command="loc:LockCryptCommands.AddDummyData" CommandParameter="templates" />
                </MenuItem>
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:ClearDatabase}" Command="loc:LockCryptCommands.ClearDatabase" />
                <Separator/>
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Options}" Command="loc:LockCryptCommands.Options" Icon="{StaticResource settings_16}" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:PasswordGenerator}" Command="loc:LockCryptCommands.GeneratePassword" />
            </MenuItem>
            <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Help}">
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:About}" Command="loc:LockCryptCommands.About" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Donate}" Click="btnDonate_Click" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:CheckForNewVersion}" Command="loc:LockCryptCommands.VersionCheck" />
                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:HelpContents}" Command="ApplicationCommands.Help" />
            </MenuItem>
        </Menu>
        <ToolBar Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3">
            <l49ui:SplitButton Style="{StaticResource SplitButton}" MainButtonLocation="Left">
                <l49ui:SplitButton.Button>
                    <l49ui:ImageButton Command="ApplicationCommands.New" Text="{lex:LocText LockCrypt.Core:Strings:Add}" Image="pack://application:,,,/Resources/images/add_32.png" ToolTip="{lex:LocText LockCrypt.Core:Strings:AddAccount}" Style="{StaticResource ToolBarButton}" />
                </l49ui:SplitButton.Button>
                <l49ui:SplitButton.MenuButton>
                    <l49ui:MenuButton MenuLocation="Bottom">
                        <l49ui:MenuButton.Menu>
                            <ContextMenu>
                                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:AddGroup}" Command="loc:LockCryptCommands.AddGroup" />
                            </ContextMenu>
                        </l49ui:MenuButton.Menu>
                    </l49ui:MenuButton>
                </l49ui:SplitButton.MenuButton>
            </l49ui:SplitButton>
            <l49ui:SplitButton Style="{StaticResource SplitButton}" MainButtonLocation="Left">
                <l49ui:SplitButton.Button>
                    <l49ui:ImageButton Command="loc:LockCryptCommands.ChangeView" Text="{lex:LocText LockCrypt.Core:Strings:ChangeView}" Image="pack://application:,,,/Resources/images/changeview_32.png" Style="{StaticResource ToolBarButton}" />
                </l49ui:SplitButton.Button>
                <l49ui:SplitButton.MenuButton>
                    <l49ui:MenuButton MenuLocation="Bottom">
                        <l49ui:MenuButton.Menu>
                            <ContextMenu>
                                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:LargeIcons}" Command="loc:LockCryptCommands.ChangeView" CommandParameter="largeicons" IsChecked="{Binding Default.PrefferedView,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource ViewPreferenceConverter},ConverterParameter=largeicons}" Checked="SavePreferences" Icon="{StaticResource view_details_16}" />
                                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:SmallIcons}" Command="loc:LockCryptCommands.ChangeView" CommandParameter="smallicons" IsChecked="{Binding Default.PrefferedView,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource ViewPreferenceConverter},ConverterParameter=smallicons}" Checked="SavePreferences" Icon="{StaticResource view_largeicons_16}" />
                                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Details}" Command="loc:LockCryptCommands.ChangeView" CommandParameter="details" IsChecked="{Binding Default.PrefferedView,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource ViewPreferenceConverter},ConverterParameter=details}" Checked="SavePreferences" Icon="{StaticResource view_smallicons_16}" />
                                <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Tiles}" Command="loc:LockCryptCommands.ChangeView" CommandParameter="tiles" IsChecked="{Binding Default.PrefferedView,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource ViewPreferenceConverter},ConverterParameter=tiles}" Checked="SavePreferences" Icon="{StaticResource view_tiles_16}" />
                            </ContextMenu>
                        </l49ui:MenuButton.Menu>
                    </l49ui:MenuButton>
                </l49ui:SplitButton.MenuButton>
            </l49ui:SplitButton>
            <ToggleButton x:Name="btnSearch" ToolTip="{lex:LocText LockCrypt.Core:Strings:Search}" Style="{StaticResource ToolbarToggleButton}" Checked="SavePreferences" Unchecked="SavePreferences">
                <ToggleButton.IsChecked>
                    <Binding Path="Default.SearchPaneVisible" Mode="TwoWay" />
                </ToggleButton.IsChecked>
                <StackPanel>
                    <Image Source="pack://application:,,,/Resources/Images/search_32.png" />
                    <TextBlock Margin="0,4,0,0" Text="{lex:LocText LockCrypt.Core:Strings:Search}"/>
                </StackPanel>
            </ToggleButton>
            <!--l49ui:ImageButton Command="ApplicationCommands.Find" Text="{lex:LocText LockCrypt.Core:Strings:Search}" Image="pack://application:,,,/Resources/images/search_32.png" Style="{StaticResource ToolBarButton}" /-->
            <l49ui:ImageButton Command="loc:LockCryptCommands.Synchronize" Text="{lex:LocText LockCrypt.Core:Strings:Synchronize}" Image="pack://application:,,,/Resources/images/sync_32.png" Style="{StaticResource ToolBarButton}" ToolTip="{lex:LocText LockCrypt.Core:Strings:SynchronizeWithMobileDevice}" />
            <l49ui:ImageButton Command="loc:LockCryptCommands.GeneratePassword" Text="{lex:LocText LockCrypt.Core:Strings:PasswordGenerator}" Image="pack://application:,,,/Resources/images/key_32.png" Style="{StaticResource ToolBarButton}" />
            <l49ui:ImageButton Command="loc:LockCryptCommands.Relock" Text="{lex:LocText LockCrypt.Core:Strings:Relock}" Image="pack://application:,,,/Resources/images/lock_32.png" Style="{StaticResource ToolBarButton}" />
        </ToolBar>

        <Expander Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" x:Name="expSearch" Style="{StaticResource ButtonlessExpander}" IsExpanded="{Binding ElementName=btnSearch,Path=IsChecked}" 
                  Padding="5,3,5,3" Background="{StaticResource AquaGradientBrush}" BorderBrush="{StaticResource SolidBorderBrush}" BorderThickness="0,0,0,1">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto" MinWidth="100"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <Label Grid.Row="0" Grid.Column="0" Content="{lex:LocText LockCrypt.Core:Strings:Name}"/>
                <ComboBox Grid.Row="0" Grid.Column="1" x:Name="cboFilterName" SelectionChanged="UpdateFilters" ItemsSource="{Binding Source={StaticResource filterTypeSource}}" />
                <TextBox Grid.Row="0" Grid.Column="2" x:Name="txtFilterName" KeyUp="txt_KeyUp" />

                <!--Label Grid.Row="1" Grid.Column="0" Content="{lex:LocText LockCrypt.Core:Strings:AccountData}"/>
                <TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" x:Name="txtFilterAccountData" KeyUp="UpdateFilters" /-->
                
                <Label Grid.Row="1" Grid.Column="0" Content="{lex:LocText LockCrypt.Core:Strings:Template}"/>
                <ComboBox Grid.Row="1" Grid.Column="1" x:Name="cboFilterTemplate" ItemsSource="{Binding Source={StaticResource templateSource}}" SelectedValuePath="ID" DisplayMemberPath="Name"
                          IsEnabled="{Binding IsChecked,ElementName=chkAllTemplates,Mode=OneWay,Converter={StaticResource BooleanInverter}}" SelectionChanged="UpdateFilters" />
                <CheckBox Grid.Row="1" Grid.Column="2" x:Name="chkAllTemplates" Content="{lex:LocText LockCrypt.Core:Strings:AllTemplates}" IsChecked="True" Checked="UpdateFilters" Unchecked="UpdateFilters" />
                
                <Expander Header="{lex:LocText LockCrypt.Core:Strings:Fields}" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" IsExpanded="{Binding Default.SearchFieldsPaneVisible,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Expanded="SavePreferences" Collapsed="SavePreferences"
                          Padding="0,1,0,0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto" MinWidth="100"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        
                        <ListBox x:Name="lstFilterFields" Grid.Row="0" Grid.Column="0" Grid.RowSpan="3" Grid.ColumnSpan="3" MinHeight="40" MaxHeight="160" SelectionMode="Single" 
                                 ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" MouseDoubleClick="lstFilterFields_MouseDoubleClick">
                            <ListBox.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Edit}" Command="loc:LockCryptCommands.Edit" Icon="{StaticResource edit_16}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" />
                                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Delete}" Command="EditingCommands.Delete" Icon="{StaticResource delete_16}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" />
                                </ContextMenu>
                            </ListBox.ContextMenu>
                        </ListBox>
                        <l49ui:ImageButton Grid.Row="0" Grid.Column="3" Command="loc:LockCryptCommands.Add" Text="{lex:LocText LockCrypt.Core:Strings:AddField}" Image="Resources/images/add_16.png" ShowText="False" ToolTip="{lex:LocText LockCrypt.Core:Strings:AddField}" Style="{StaticResource ToolBarButton}"
                                         CommandParameter="{Binding SelectedItem,ElementName=lstFilterFields}" />
                        <l49ui:ImageButton Grid.Row="1" Grid.Column="3" Command="loc:LockCryptCommands.Edit" Text="{lex:LocText LockCrypt.Core:Strings:EditField}" Image="Resources/images/edit_16.png" ShowText="False" ToolTip="{lex:LocText LockCrypt.Core:Strings:EditField}" Style="{StaticResource ToolBarButton}"
                                         CommandParameter="{Binding SelectedItem,ElementName=lstFilterFields}" />
                        <l49ui:ImageButton Grid.Row="2" Grid.Column="3" Command="EditingCommands.Delete" Text="{lex:LocText LockCrypt.Core:Strings:DeleteField}" Image="Resources/images/delete_16.png" ShowText="False" ToolTip="{lex:LocText LockCrypt.Core:Strings:DeleteField}" Style="{StaticResource ToolBarButton}"
                                         CommandParameter="{Binding SelectedItem,ElementName=lstFilterFields}" />
                    </Grid>
                </Expander>
                
                <CheckBox Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3" x:Name="chkEmptyGroups" Content="{lex:LocText LockCrypt.Core:Strings:ShowEmptyGroups}" IsChecked="True" Checked="UpdateFilters" Unchecked="UpdateFilters" />
                
                <CheckBox Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="3" x:Name="chkLiveFilter" Content="{lex:LocText LockCrypt.Core:Strings:SearchWhileTyping}" IsChecked="{Binding Default.LiveFilter,Mode=TwoWay}" Checked="chkLiveFilter_Checked" />
                <StackPanel Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="3" Orientation="Horizontal">
                    <l49ui:ImageButton Margin="0,2,2,2" Image="pack://application:,,,/Resources/images/filter_16.png" ImageLocation="Left" Text="{lex:LocText LockCrypt.Core:Strings:Search}" MinWidth="70" Command="ApplicationCommands.Find" IsDefault="True">
                        <Button.Style>
                            <Style TargetType="{x:Type l49ui:ImageButton}" BasedOn="{StaticResource {x:Type l49ui:ImageButton}}">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ElementName=chkLiveFilter, Path=IsChecked}" Value="True">
                                        <Setter Property="Button.IsEnabled" Value="false"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                    </l49ui:ImageButton>
                    <l49ui:ImageButton Image="pack://application:,,,/Resources/images/unfilter_16.png" ImageLocation="Left" Text="{lex:LocText LockCrypt.Core:Strings:ClearSearch}" MinWidth="70" Command="ApplicationCommands.Find" CommandParameter="clear" />
                </StackPanel>
            </Grid>
        </Expander>
                
        <TreeView Grid.Row="3" Grid.Column="0" x:Name="treAccounts" PreviewMouseRightButtonDown="tre_PreviewMouseRightButtonDown" MouseDoubleClick="tre_MouseDoubleClick" ItemTemplateSelector="{StaticResource TreeTemplateSelector}" 
                  AllowDrop="True" DragEnter="tre_DragEnter" Drop="tre_Drop" Padding="0">
            <TreeView.Resources>
                <Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource {x:Type TreeViewItem}}">
                    <Setter Property="IsExpanded" Value="True"/>
                    <EventSetter Event="PreviewMouseLeftButtonDown" Handler="tre_PreviewMouseLeftButtonDown"/>
                    <EventSetter Event="MouseMove" Handler="tre_MouseMove"/>
                    <Style.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsChecked,ElementName=chkEmptyGroups}" Value="False"/>
                                <Condition Binding="{Binding HasItems,RelativeSource={RelativeSource Self}}" Value="False"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Visibility" Value="Hidden"/>
                        </MultiDataTrigger>
                    </Style.Triggers>
                </Style>
            </TreeView.Resources>
            <TreeView.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:AddGroup}" Command="loc:LockCryptCommands.AddGroup" Icon="{StaticResource add_16}" CommandParameter="context" Visibility="{Binding PlacementTarget.SelectedItem,RelativeSource={RelativeSource AncestorType=ContextMenu},Converter={StaticResource NestableToVisibilityConverter},ConverterParameter=group}" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:AddAccount}" Command="ApplicationCommands.New" Icon="{StaticResource add_16}" CommandParameter="context" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Edit}" Command="ApplicationCommands.Properties" Icon="{StaticResource edit_16}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" />
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:Delete}" Command="ApplicationCommands.Delete" Icon="{StaticResource delete_16}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" />
                    <Separator/>
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:AutoType}" Command="loc:LockCryptCommands.AutoType" Icon="{StaticResource keyboard_16}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" Visibility="{Binding PlacementTarget.SelectedItem,RelativeSource={RelativeSource AncestorType=ContextMenu},Converter={StaticResource NestableToVisibilityConverter},ConverterParameter=account}" 
                              ToolTip="{lex:LocText LockCrypt.Core:Strings:AutoTypeSelected}"/>
                    <MenuItem Header="{lex:LocText LockCrypt.Core:Strings:CreateCopy}" Command="loc:LockCryptCommands.CreateCopy" Icon="{StaticResource copy_16}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" Visibility="{Binding PlacementTarget.SelectedItem,RelativeSource={RelativeSource AncestorType=ContextMenu},Converter={StaticResource NestableToVisibilityConverter},ConverterParameter=account}" />
                </ContextMenu>
            </TreeView.ContextMenu>
        </TreeView>
        
        <GridSplitter Grid.Row="3" Grid.Column="1" ResizeDirection="Columns" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
        
        <loc:AccountView Grid.Row="3" Grid.Column="2" x:Name="accountView" SelectedItem="{Binding SelectedItem,ElementName=treAccounts,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
                         CurrentView="{Binding Default.PrefferedView,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" RequestNavigate="accountView_RequestNavigate"/>
        
        <StatusBar Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3" MinHeight="24">
            <StatusBar.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="2*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem Grid.Column="0">
                <StackPanel x:Name="pnlCurrentDB" Orientation="Horizontal" VerticalAlignment="Center">
                    <Image Source="pack://application:,,,/Resources/Images/database_16.png" Width="16" VerticalAlignment="Center"/>
                    <TextBlock x:Name="txtCurrentDBPath"/>
                </StackPanel>
            </StatusBarItem>
            <StatusBarItem Grid.Column="1">
                <Separator/>
            </StatusBarItem>
            <StatusBarItem Grid.Column="2">
                <DockPanel>
                    <TextBlock x:Name="lblRecordCount" DockPanel.Dock="Left" Visibility="Collapsed" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Margin="2" />
                    <TextBlock x:Name="lblStatus" DockPanel.Dock="Left" Visibility="Hidden" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Margin="2" />
                    <ProgressBar x:Name="prgStatus" DockPanel.Dock="Right" IsIndeterminate="True" MinWidth="40" Visibility="Hidden" />
                </DockPanel>
            </StatusBarItem>
            <StatusBarItem Grid.Column="3">
                <Separator/>
            </StatusBarItem>
            <StatusBarItem Grid.Column="4">
                <Image x:Name="imgFirefoxStatus" Width="16" VerticalAlignment="Center">
                    <Image.Style>
                        <Style TargetType="{x:Type Image}">
                            <Style.Triggers>
                                <Trigger Property="UIElement.IsEnabled" Value="False">
                                    <Setter Property="UIElement.OpacityMask" Value="{StaticResource disabledMask}"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                    <!--Image.Style>
                        <Style targett
                    </Image.Style-->
                </Image>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Window>
